Skip to content

feat(graphs): add opt-in traffic auto-scaling - #3

Merged
CodeWithMa merged 3 commits into
CodeWithMa:mainfrom
CodeWithMaBot:feat/auto-scale
Nov 28, 2026
Merged

CodeWithMa merged 3 commits into
CodeWithMa:mainfrom
CodeWithMaBot:feat/auto-scale

Conversation

@CodeWithMaBot

@CodeWithMaBot CodeWithMaBot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

Make quiet traffic visible and keep bursts from flattening against a fixed graph ceiling. Closes #1.

What changed

  • Add --auto-scale with independent ceilings per interface and direction. Ceilings rise immediately and fall in steps after sustained low traffic.
  • Keep explicit -i and -o overrides fixed, including 0 for the fixed default. Document the flag in --help and the README.
  • Bump the package version to 0.1.5.

Tradeoffs

Older spikes can clip as the ceiling drops. They no longer keep quiet traffic compressed for as long as they remain on screen.

Blast Radius

Without --auto-scale, graph scaling stays unchanged. Traffic statistics are unaffected in either mode.

Verification

  • cargo test --locked -- --test-threads=1
  • cargo test --release --locked --test linux_pty -- --test-threads=1
  • cargo fmt --check and cargo clippy --locked --all-targets -- -D warnings
  • Verified nload-rs --version reports 0.1.5.

Summary by CodeRabbit

  • New Features
    • Added --auto-scale to adjust incoming and outgoing graph ceilings independently as traffic changes. Explicit direction limits remain fixed, and zero restores the default fixed ceiling.
    • Incoming and outgoing graphs default to ceilings of 10,240 kBit/s.
  • Documentation
    • Updated the quick start guide with auto-scaling behavior, clipping details, and an example using a mix of automatic and fixed ceilings.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CLI adds opt-in, independent auto-scaling for incoming and outgoing traffic, with per-direction fixed overrides. The monitor adjusts automatic ceilings from measured rates and provides current ceilings to graph views.

Changes: Traffic graph auto-scaling

Layer / File(s) Summary
CLI scaling policy and documentation
src/arguments.rs, README.md, Cargo.toml, src/application/tests.rs
The parser supports --auto-scale, independent -i and -o fixed overrides, and fixed defaults when auto-scaling is omitted. Help text, README guidance, and tests reflect the policy. The package version changes to 0.1.5.
Monitor scaling and graph views
src/monitor.rs, src/proc_sampler.rs, src/screen.rs, src/terminal/runtime/tests.rs, src/terminal/session/tests.rs, tests/linux_pty.rs
Each direction maintains its own scale. Automatic ceilings rise to match measured rates and decrease after sustained low traffic. Direction views use the current ceiling. Tests cover scaling behavior, fixed-policy setup, and a PTY traffic burst.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLIParser
  participant Monitor
  participant DirectionScale
  participant DirectionView
  participant Terminal
  User->>CLIParser: Set --auto-scale and optional -i/-o values
  CLIParser->>Monitor: Pass per-direction CeilingPolicy values
  Monitor->>DirectionScale: Initialize scale from policy
  Monitor->>DirectionScale: Update scale from measured rate
  Monitor->>DirectionView: Provide total and current ceiling
  DirectionView->>Terminal: Supply graph view for display
Loading

Suggested reviewers: codewithma

Merge Risk: Minimal · up to 8c40d · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title 'feat(graphs): add opt-in traffic auto-scaling' names the main change. The PR adds an opt-in --auto-scale flag that lets incoming and outgoing graph ceilings scale independently. The title i…
Linked Issues check Passed Issue #1 coding requirements are met, based on the whole-PR summary for merge base 13d2464 to head 8c40d97. No repository inspection was needed. (1) Opt-in flag: src/arguments.rs accepts `--auto-scal…
Out of Scope Changes check Passed All changes map to the PR objectives or to supporting work. The --auto-scale option, CeilingPolicy, monitor scaling logic, and DirectionView changes implement issue #1. The README and --help updat…
Full details: Title check

Explanation

The title 'feat(graphs): add opt-in traffic auto-scaling' names the main change. The PR adds an opt-in --auto-scale flag that lets incoming and outgoing graph ceilings scale independently. The title is specific, short, and matches the linked issue and the changeset. It has no file lists, emojis, or vague terms.

Full details: Linked Issues check

Explanation

Issue #1 coding requirements are met, based on the whole-PR summary for merge base 13d2464 to head 8c40d97. No repository inspection was needed. (1) Opt-in flag: src/arguments.rs accepts --auto-scale. Without it, unspecified directions stay Fixed(DEFAULT_CEILING_BYTES). (2) Independent scaling: Ceilings holds a CeilingPolicy per direction, and src/monitor.rs scales each direction separately. (3) Rise and fall: an automatic ceiling rises to the next power of two above the measured rate at once. It halves only after the rate stays at or below one quarter of the ceiling for two seconds. This matches the issue's fast-rise and gradual-fall requirement. (4) Overrides: an explicit -i or -o fixes that direction, and the other direction can auto-scale. An explicit zero restores that direction's fixed default. (5) Display: DirectionView receives a concrete ceiling from each direction's scale. The PTY test checks the incoming and outgoing ceiling displays. (6) Docs: --help text and README were updated. (7) Tests: unit tests cover automatic scaling, per-direction and per-interface scaling, recovery, and saturation. A Linux PTY test covers the flag end to end. Residual uncertainty: the summary does not show the exact rendering of the ceiling label, and the no-jitter criterion relies on the two-second hold and halving rule.

Full details: Out of Scope Changes check

Explanation

All changes map to the PR objectives or to supporting work. The --auto-scale option, CeilingPolicy, monitor scaling logic, and DirectionView changes implement issue #1. The README and --help updates document the flag, as #1 requires. Test updates that switch fixed ceilings to CeilingPolicy::Fixed(...) in src/application/tests.rs, src/proc_sampler.rs, src/screen.rs, src/terminal/runtime/tests.rs, and src/terminal/session/tests.rs follow from the new type. The Cargo.toml version bump to 0.1.5 is listed in the PR description and is a stated change, so it is in scope by declared intent. Cargo.lock is excluded from review under the !**/*.lock rule. Its absence is not treated as evidence either way, and it does not affect this verdict. No unrelated behavior change appears in the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 28b744bb-faa9-4782-b3d5-33b074581316
Commits

Reviewing files that changed from the base of the PR and between 13d2464 and 8c40d97.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 10

  • Cargo.toml
  • README.md
  • src/application/tests.rs
  • src/arguments.rs
  • src/monitor.rs
  • src/proc_sampler.rs
  • src/screen.rs
  • src/terminal/runtime/tests.rs
  • src/terminal/session/tests.rs
  • tests/linux_pty.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@CodeWithMa
CodeWithMa merged commit dfb8af8 into CodeWithMa:main Nov 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an opt-in auto-scale mode for traffic graphs

2 participants